<template>
  <div class="indices">
    <div class="title">生活指数</div>
    <el-row v-if="indices.length">
      <template v-for="(item, index) in indices" :key="item.title">
        <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <IndicesContent
            @click="jump(index)"
            :title="item.title"
            :level="item.level"
            :x="
              index > 3
                ? `${-69 - (index - 4) * 60}px`
                : `${-69 - index * 60}px`
            "
            :y="index > 3 ? '-70px' : '-4px'"
            :index="index"
          />
        </el-col>
      </template>
    </el-row>
  </div>
</template>

<script setup>
import IndicesContent from "@/components/main/indices-content.vue";

import useIndicesStore from "@/stores/modules/indices";
import { useRouter } from "vue-router";

const props = defineProps({
  indices: {
    type: Array,
  },
});

const router = useRouter();
const indicesStore = useIndicesStore();

const jump = (index) => {
  router.push({
    path: "/indices",
  });
  indicesStore.currentIndex = index;
};
</script>

<style lang="less" scoped>
.indices {
  padding: 30px 0 14px;
  margin-bottom: 16px;

  border-radius: 16px;
  background-color: #f7f8f9;
  border: 1px solid #f2f4fa;
  .title {
    font-size: 20px;
    font-weight: 500;
    line-height: 22px;
    text-align: center;
    margin-bottom: 28px;
  }
}
</style>